#include <bits/stdc++.h>
using namespace std;

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> stk;
        int len = tokens.size();
        for(int i = 0; i < len; i++) {
            if(tokens[i] == "+" || tokens[i] == "-" ||
               tokens[i] == "*" || tokens[i] == "/") {
                int a = stk.top();
                stk.pop();
                int b = stk.top();
                stk.pop();
                if(tokens[i] == "+") {
                    stk.push(b + a);
                } else if(tokens[i] == "-") {
                    stk.push(b - a);
                } else if(tokens[i] == "*") {
                    stk.push(b * a);
                } else {
                    stk.push(b / a);
                }
            } else {
                stk.push(stoi(tokens[i]));
            }
        }
        return stk.top();
    }
};

int main() {
    Solution s;
    vector<string> v;
    cout<<s.evalRPN(v)<<endl;
    return 0;
}